package com.mybatisx.mybatisplus.controller;


import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;

/**
 * 功能描述: <br>
 SessionShareController <br>
 * 〈session共享控制器〉
 * @Param:
 * @Return:
 * @Author: wuyue
 * @Date: 2021/7/6 14:10
 */
@RestController
@RequestMapping(value = "/session")
public class SessionShareController {

    @Value("${server.port}")
    Integer port;


    @GetMapping(value = "/set")
    public String set(HttpSession session){
        session.setAttribute("user","hello  world");
        return String.valueOf(port);
    }

    @GetMapping(value = "get")
    public String get(HttpSession session){
        return "用户:"+session.getAttribute("user")+",端口:"+port;
    }
}
